import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    studentList: [
      {
        name: '张雨豪',
        age: 18,
        sex: '男'
      },
      {
        name: '张伟',
        age: 19,
        sex: '男'
      }
    ]
  },
  mutations: {
    addStu(state, obj) {
      state.studentList.push(obj)
    },
    delStu(state, index) {
      state.studentList.splice(index, 1)
    }
  }
})

export default store